import React from 'react';
import {
  Image,
  StyleProp,
  StyleSheet,
  View,
  Text,
  ViewStyle,
} from 'react-native';

interface ProfileCardProp {
  style?: StyleProp<ViewStyle>;
}

export default function ProfileCard(prop: ProfileCardProp) {
  return (
    <View style={[styles.container, prop.style]}>
      <View style={styles.userInfo}>
        <Image
          style={styles.avatar}
          source={{
            uri: 'https://fit-club-1251103125.cos.ap-shanghai.myqcloud.com/avatar-4-avatar_100.jpg',
          }}
        />
        <View style={styles.usernameContainer}>
          <Text style={styles.username}>沈三</Text>
          <Text style={styles.userLevel}>Lv0 初级用户</Text>
        </View>
      </View>
      <View style={styles.selfDataContainer}>
        <Text style={styles.selfDataTitle}>个人数据</Text>
        <View style={styles.selfData}>
          <View style={styles.dataItem}>
            <View style={styles.dataValueContainer}>
              <Text style={styles.dataValue}>787</Text>
              <Text style={styles.dataUnit}>分钟</Text>
            </View>
            <Text style={styles.dataName}>锻炼时长</Text>
          </View>
          <View style={styles.dataItem}>
            <View style={styles.dataValueContainer}>
              <Text style={styles.dataValue}>1.3</Text>
              <Text style={styles.dataUnit}>万卡</Text>
            </View>
            <Text style={styles.dataName}>消耗热量</Text>
          </View>
          <View style={styles.dataItem}>
            <View style={styles.dataValueContainer}>
              <Text style={styles.dataValue}>51</Text>
              <Text style={styles.dataUnit}>kg</Text>
            </View>
            <Text style={styles.dataName}>体重</Text>
          </View>
          <View style={styles.dataItem}>
            <View style={styles.dataValueContainer}>
              <Text style={styles.dataValue}>8</Text>
              <Text style={styles.dataUnit}>kg</Text>
            </View>
            <Text style={styles.dataName}>已减</Text>
          </View>
        </View>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    padding: 12,
    borderRadius: 6,
  },
  userInfo: {
    flexDirection: 'row',
  },
  avatar: {
    height: 64,
    width: 64,
    borderRadius: 32,
    borderWidth: 0.5,
    borderColor: '#ccc',
  },
  usernameContainer: {
    flex: 1,
    marginLeft: 12,
  },
  username: {
    fontSize: 18,
    lineHeight: 26,
  },
  userLevel: {
    fontSize: 12,
    lineHeight: 26,
    color: '#666',
  },
  selfDataContainer: {
    marginTop: 12,
  },
  selfDataTitle: {
    fontSize: 14,
    color: '#666',
  },
  selfData: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    padding: 12,
  },
  dataItem: {
    alignItems: 'center',
  },
  dataValueContainer: {
    flexDirection: 'row',
    alignItems: 'flex-end',
  },
  dataValue: {
    fontSize: 20,
    lineHeight: 20,
    color: '#5b308b',
  },
  dataUnit: {
    fontSize: 12,
    lineHeight: 20,
  },
  dataName: {
    lineHeight: 26,
  },
});
